package sample.job.start;

import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.TextArea;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import sample.server.jobServer;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author 杨佳颖
 * @Data 2022-03-21 9:22
 **/
public class CopyStart implements Job {

    public static ExecutorService pool = Executors.newSingleThreadExecutor();

    public jobServer jobServer = new jobServer();

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        pool.execute(() -> {
            JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
            String dbType = jobDataMap.getString("dbType");
            String dburl = jobDataMap.getString("dburl");
            String dbuser = jobDataMap.getString("dbuser");
            String dbpass = jobDataMap.getString("dbpass");
            String dbport = jobDataMap.getString("dbport");
            String dbname = jobDataMap.getString("dbname");
            String dbsql = jobDataMap.getString("dbsql");
            String dbfield = jobDataMap.getString("dbfield");
            String savepath = jobDataMap.getString("savepath");
            String xcs = jobDataMap.getString("xcs");
            String serverIP = jobDataMap.getString("serverIP");
            String replacementLocation = jobDataMap.getString("replacementLocation");
            String replaceContent = jobDataMap.getString("replaceContent");
            String cronTime = jobDataMap.getString("cronTime");
            TextArea log = (TextArea) jobDataMap.get("log");
            ProgressBar jindutiao = (ProgressBar) jobDataMap.get("jindutiao");
            Label jindutiaowenzi = (Label) jobDataMap.get("jindutiaowenzi");
            jobServer.timedTask(dbType, dburl, dbuser, dbpass, dbport, dbname, dbsql, dbfield, savepath, xcs, serverIP, replacementLocation, replaceContent, cronTime, log, jindutiao, jindutiaowenzi);
        });
    }
}
